import { isPhoneNumber } from '@/utils/index'

export const formRules = {
  levelId: [{ required: true, validator: notEmpty, msg: '请选择事故等级', trigger: ['blur', 'change'] }],
  status: [{ required: true, validator: notEmpty, msg: '请选择处理状态', trigger: ['blur', 'change'] }],
  address: [{ required: true, validator: notEmpty, msg: '请输入事故地点', trigger: ['blur', 'change'] }],
  departmentId: [{ required: true, validator: notEmpty, msg: '请选择责任部门', trigger: ['blur', 'change'] }],
  accidentTime: [{ required: true, validator: notEmpty, msg: '请选择事故时间', trigger: ['blur', 'change'] }],
  declarePersonId: [{ required: true, validator: notEmpty, msg: '请选择申报人', trigger: ['blur', 'change'] }],
  remark: [{ required: true, validator: notEmpty, msg: '请输入事故描述', trigger: ['blur', 'change'] }],
  processMsg: [{ required: true, validator: notEmpty, msg: '请输入事故过程', trigger: ['blur', 'change'] }],
  reasonMsg: [{ required: true, validator: notEmpty, msg: '请输入事故原因', trigger: ['blur', 'change'] }],
  resultMsg: [{ required: true, validator: notEmpty, msg: '请输入处理结果', trigger: ['blur', 'change'] }],
  accidentPhotos: [{ required: true, validator: notEmpty, msg: '请上传事故照片', trigger: ['blur', 'change'] }],
}



// 校验不能为空
function notEmpty(rule, value, callback) {
  if (!value) {
    return callback(new Error(rule.msg))
  }else{
    if(rule.field === 'accidentPhotos' && (!value || value.length === 0)){
      return callback(new Error(rule.msg))
    }
    return callback()
  }
}


export const levelList = [
  {name: '一般事故', id: 1},
  {name: '较大事故', id: 2},
  {name: '重大事故', id: 3},
  {name: '特别重大事故', id: 4},
]
export const statusList = [
  {name: '待提交', id: 1}, // 信息、结果均可编辑
  {name: '待处理', id: 2}, // 信息只读，结果可编辑
  {name: '已处理', id: 3}, // 信息、结果均只读
  {name: '无法处理', id: 4}, // 信息、结果均只读
]

export const personalColumn = [
  { prop: 'name', label: '姓名', align: 'center', },
  { prop: 'phone', label: '联系电话', align: 'center'},
  { prop: 'position', label: '岗位', align: 'center'},
  { prop: 'departmentId', label: '所属部门', align: 'center'},
]

export const laborColumn = [
  { prop: 'name', label: '姓名', align: 'center', },
  { prop: 'phone', label: '联系电话', align: 'center'},
  { prop: 'idCard', label: '身份证号', align: 'center', width: 180},
  { prop: 'skillName', label: '工种', align: 'center'},
  { prop: 'entryTime', label: '入职时间', align: 'center'},
  { prop: 'status', label: '状态', align: 'center'},
  { prop: 'emergencyContact', label: '紧急联系人', align: 'center'},
  { prop: 'urgentPhone', label: '紧急联系人电话', align: 'center'},
]


export const emergencyColumn = [
  { prop: 'code', label: '预案编号', align: 'center', width: 160},
  { prop: 'name', label: '预案名称', align: 'center', },
  { prop: 'type', label: '预案类型', align: 'center'},
  { prop: 'departmentId', label: '编制部门', align: 'center'},
  { prop: 'emergencyTime', label: '编制时间', align: 'center', width: 230},
]